0.1 Read and clean data

## [1] "/Users/jouta1/Desktop/github.nosync/tlao-public"

pre-exclusion N and age

## # A tibble: 1 × 1
##   mean_age
##      <dbl>
## 1     6.55

1 Data quality checks, fixes, exclusions

2 fix s085

2.1 Trial Exclusions and Subject Exclusions

subjects excluded (20): - technical difficulties (5): s028, s029, s030, s042, s078 (i.e. stimuli didn’t loop, pyhab keeps freezing, no sound, ) - experimenter error (2): s035, s064 (forgetting to record shared screen, not recording session) - inattention (4): s039, s053, s058, s073 - poor video quality (1): s043 - external distraction (3): s068, s069, s075 (siblings, caregiver) - trial exclusions resulting in no trials left/accumulated looking time less than 3 seconds (5): s038, s049, s062, s067, s071 (and thus had to exclude non-consecutive test trials)

2.2 Wrangle data for plotting

2.3 Exploratory checks

## Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(count)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

3 Plots

3.1 Age, Conditions

## # A tibble: 1 × 1
##       n
##   <int>
## 1    36

## [1] 5.07 8.89
## [1] 6.84

3.2 Plot all trials

3.3 Plot only test events

## # A tibble: 2 × 3
##   trialType   mean    sd
##   <chr>      <dbl> <dbl>
## 1 expected    22.0  18.2
## 2 unexpected  20.2  16.2

4 Exploring training effect

4.1 median splitting training time

# trianing effect linear model

## 
## Call:
## lm(formula = voe_effect ~ train_duration, data = d_voe)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -40.27 -15.48   1.21   5.70  42.54 
## 
## Coefficients:
##                                         Estimate Std. Error t value Pr(>|t|)
## (Intercept)                                 2.70       4.64    0.58     0.56
## train_durationtrain shorter than median    -8.16       6.22   -1.31     0.20
## 
## Residual standard error: 18.5 on 34 degrees of freedom
## Multiple R-squared:  0.0482, Adjusted R-squared:  0.0202 
## F-statistic: 1.72 on 1 and 34 DF,  p-value: 0.198

4.2 correlation between training time and voe effect

5 age differences in correlations

5.1 Plot all trials with median age split

5.2 Plot test trials

5.3 Plot test trials by condition

5.4 conditions again, different labels

5.5 Plot first test pair

6 Statistical analysis

d_icatcher_stats <- d_icatcher_plot_first_pair %>% 
  filter(Trials.trialType == "test") %>% 
  mutate(order = ifelse(condLabel %in% c(1, 4), "expected_first", "unexpected_first")) %>% 
  filter(!is.nan(Log_looks) & !is.infinite(Log_looks)) %>% 
  mutate(Index = row_number())

model <- lmer(Looks.duration_onLooks ~ trialType + (1 | SubjectInfo.subjID), data = d_icatcher_stats)
summary(model)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Looks.duration_onLooks ~ trialType + (1 | SubjectInfo.subjID)
##    Data: d_icatcher_stats
## 
## REML criterion at convergence: 590
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.471 -0.523 -0.352  0.494  2.029 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  SubjectInfo.subjID (Intercept) 120      11.0    
##  Residual                       179      13.4    
## Number of obs: 71, groups:  SubjectInfo.subjID, 36
## 
## Fixed effects:
##                     Estimate Std. Error    df t value Pr(>|t|)    
## (Intercept)            22.03       2.88 59.74    7.64  2.1e-10 ***
## trialTypeunexpected    -1.63       3.19 34.82   -0.51     0.61    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## trlTypnxpct -0.542
performance::check_model(model)

#with log-transformation

model_log <- lmer(Log_looks ~ trialType + (1 | SubjectInfo.subjID) + age_months_decimal + order, data = d_icatcher_stats)
summary(model_log)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## Log_looks ~ trialType + (1 | SubjectInfo.subjID) + age_months_decimal +  
##     order
##    Data: d_icatcher_stats
## 
## REML criterion at convergence: 178
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.7609 -0.6118  0.0184  0.5948  1.7881 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  SubjectInfo.subjID (Intercept) 0.370    0.608   
##  Residual                       0.408    0.639   
## Number of obs: 71, groups:  SubjectInfo.subjID, 36
## 
## Fixed effects:
##                       Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)             2.6468     0.8078 33.8196    3.28   0.0024 **
## trialTypeunexpected    -0.0339     0.1521 34.7899   -0.22   0.8249   
## age_months_decimal      0.0275     0.1107 33.3795    0.25   0.8051   
## orderunexpected_first  -0.2481     0.2632 33.1789   -0.94   0.3526   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) trlTyp ag_mn_
## trlTypnxpct -0.081              
## ag_mnths_dc -0.973 -0.014       
## ordrnxpctd_ -0.373  0.010  0.243
performance::check_model(model_log)